\documentclass[12pt]{article}

\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{hyperref}
\hypersetup{
    colorlinks,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black
}
\pagestyle{plain}
\setcounter{secnumdepth}{3}

\topmargin=0cm
\oddsidemargin=0cm
\textheight=22.0cm
\textwidth=16cm
\parindent=0cm
\parskip=0.15cm
\topskip=0truecm
\raggedbottom
\abovedisplayskip=3mm
\belowdisplayskip=3mm
\abovedisplayshortskip=0mm
\belowdisplayshortskip=2mm
\normalbaselineskip=12pt
\normalbaselines

\begin{document}

\thispagestyle{empty}
\vspace*{0.5in}
\centerline{\bf\Large Design Document}

\vspace*{0.5in}
\centerline{\bf\Large Team 3}

\vspace*{0.5in}
\centerline{\bf\Large 5 March 2012}

%====================================================
% STUDENT NAMES TABLE
%====================================================
%
\vspace*{1.5in}
\begin{table}[htbp]
\caption{Team}
\begin{center}
\begin{tabular}{|l | c|}
\hline
\multicolumn{1}{|c|}{Name} & \multicolumn{1}{|c|}{ID Number} \\
\hline\hline
Amer Alhalabi & 9067272 \\
Dmitriy Fingerman & 6436579 \\
Zoardar Golam & 1114441 \\
Rajwinder Kaur & 6282490 \\
Rolf Schmidt & 9538267 \\
\hline
\end{tabular}
\end{center}
\end{table}

\clearpage
\tableofcontents
%\clearpage
\listoffigures
%\clearpage
\listoftables

%====================================================
% INTRODUCTION
%====================================================
%
\clearpage
\section{Introduction}

This document describes the architectural design of the Task Management System using an architectural diagram and a package diagram. The design of the subsystems and their interfaces is included and illustrated with subsystem class diagrams. A detailed module diagram presents the internal structure of the subsystems and each class is described briefly.

Two use cases serve as dynamic design scenario examples. These examples show how system-level services are provided.

Finally, the graphical user interface (GUI) design is presented.
%====================================================
% ARCHITECTURAL DESIGN
%====================================================
%
\section{Architectural Design} \label{sec:arch}

%This section must give a high-level description of the system in terms of its modules
%and their respective purpose and exact interfaces.

%====================================================
% ARCHITECTURAL DIAGRAM
%====================================================
%
\subsection{Architectural Diagram}

\begin{figure}[htb]
	\centering
		\includegraphics[width=0.6\textwidth]{img/Architectural_Diagram.png}
	\caption{Architectural diagram}
	\label{fig:arch_diag}
\end{figure}

The architectural diagram in figure ~\ref{fig:arch_diag} presents the subsystems of TMS at a high level. The Data handler subsystem contains the task management data model and methods for data manipulation. The User interface subsystem contains data presentation functionality like tree and table views. The Event handler subsystem handles user input. Both the User interface and the Data handler subsystems communicate with the Event handler, but do not communicate with each other. The rationale of this design is to separate the domain logic, input and presentation functionality, which will permit independent development, testing and maintenance of each module.

\begin{figure}[htb]
	\centering
		\includegraphics[width=0.6\textwidth]{img/Package_Diagram.png}
	\caption{Package diagram}
	\label{fig:pack_diag}
\end{figure}

The package diagram in figure~\ref{fig:pack_diag} shows the hierarchical organization of the TMS source code.

There are two packages in the \textit{src} folder:
\begin{itemize}
	\item images
	\item tms
\end{itemize}

The \textit{images} package contains graphical resources for the TMS such as button glyphs and action images.

There following two folders are found inside the \textit{tms} package:
\begin{itemize}
	\item model
	\item ui
\end{itemize}

The \textit{model} folder contains all the model classes of the TMS (\textit{e.g.} Task, Person, etc.) whereas the \textit{ui} folder contains the classes that make up the user interface (\textit{i.e.} Main and About). 

%====================================================
% SUBSYSTEM INTERFACES SPECS
%====================================================
%
\subsection{Subsystem Interface Specifications}

The following section will describe the interfaces between the subsystems in detail.
%Specification of the software interfaces between the subsystems,
%i.e. specific messages (or function calls) that are exchanged by the subsystems.
%These are also often called ``Module Interface Specifications''.
%Description of the parameters to be passed into these function calls in order to have a service fulfilled, including valid and invalid ranges of values.
%Each subsystem interface must be presented in a separate subsection.

\subsubsection{Data Handler Subsystem}

%-----------------------------------------------------
% TaskTree.getInstance
%-----------------------------------------------------
%
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getInstance} \\
%\hline
Arguments & None \\
%\hline
Return results & TaskTree \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & If the singleton TaskTree was null, then it has been constructed. Otherwise, the state does not change. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns the TaskTree singleton. This singleton serves as a model for the table view of tasks and the tree view of tasks.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.getTaskMap 
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getTaskMap} \\
%\hline
Arguments & None \\
%\hline
Return results & TreeMap \textless String, Task\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module has not changed. \\
%\hline
Exceptions & None \\
%\hline
Comments & The TreeMap returned by this method maps task ids to the corresponding Task objects.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.getTaskList 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getTaskList} \\
%\hline
Arguments & None \\
%\hline
Return results & List\textless Task\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns a list of Task objects.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.getTopLevelTasklist 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getTopLevelTasklist} \\
%\hline
Arguments & None \\
%\hline
Return results & List\textless Task\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns a list of Top-level root Task objects excluding subtasks.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.getFlatTasklist 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getFlatTasklist} \\
%\hline
Arguments & None \\
%\hline
Return results & List\textless Task\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns a list of all Tasks and subtasks. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.setTaskList 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.setTaskList} \\
%\hline
Arguments & List\textless Task\textgreater \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The tasks in TaskTree will be replaced by the tasks passed as an argument. \\
%\hline
Exceptions & None \\
%\hline
Comments & None.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.clear 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.clear} \\
%\hline
Arguments & None \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & All tasks are removed from taskList TreeMap\textless String, Task\textgreater. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event to update the views.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.addTask
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.addTask} \\
%\hline
Arguments & None \\
%\hline
Return results & Task task \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & A new Task object has been added to the taskList TreeMap\textless String, Task\textgreater. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method creates a new Task object with default values and a unique ID and adds it to the TreeMap. Then it fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.addSubtask
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.addSubtask} \\
%\hline
Arguments & Task parentTask \\
%\hline
Return results & Task task \\
%\hline
Pre-conditions & parentTask is not null and exists in the taskList \\
%\hline
Post-conditions & A new subTask object has been added to the taskList TreeMap\textless String, Task\textgreater. The subtask has been added to parentTask's subtasks list\\
%\hline
Exceptions & None \\
%\hline
Comments & This method creates a new Task object with default values and a unique ID and adds it to the TreeMap and to parentTask subtasks list. Then it fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.removeTask
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.removeTask} \\
%\hline
Arguments & Task task \\
%\hline
Return results & None \\
%\hline
Pre-conditions & task is not null and exists in the taskList \\
%\hline
Post-conditions & The Task object task and its subtasks (if they exist) have been removed from the taskList TreeMap\textless String, Task\textgreater. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method removes a Task and its subtasks from the taskList object and fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.getTask
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.getTask} \\
%\hline
Arguments & int id \\
%\hline
Return results & Task task \\
%\hline
Pre-conditions & a Task associated with id exists in the taskList \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & None \\
%\hline
Comments & None \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.setUniqueId
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.setUniqueId} \\
%\hline
Arguments & Task task \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & A unique taskId is generated and assigned to the argument Task task. \\
%\hline
Exceptions & None \\
%\hline
Comments & None \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.loadXMLFile
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.loadXMLFile} \\
%\hline
Arguments & String fileName \\
%\hline
Return results & boolean \\
%\hline
Pre-conditions & fileName is not null and is not an empty string. The content of the file adheres to the Input File Format guidelines\\
%\hline
Post-conditions & taskList TreeMap\textless String, Task\textgreater\ has been loaded from the input file. \\
%\hline
Exceptions & File does not exist or I/O exception\\
%\hline
Handling & Clear the content of the taskList, print out an error message, and return false. \\
%\hline
Comments & This method receives as input a file name and loads the tasks from this file. It returns true on success and false on failure. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.saveCSVFile
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.saveCSVFile} \\
%\hline
Arguments & String fileName \\
%\hline
Return results & boolean \\
%\hline
Pre-conditions & fileName is not null and is not an empty string. \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & I/O exception \\
%\hline
Handling &  Print out an error message and return false. \\ 
%\hline
Comments & This method saves tasks data to a CSV file. It returns true on success and false on failure. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% TaskTree.saveXMLFile
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{TaskTree.saveXMLFile} \\
%\hline
Arguments & String fileName \\
%\hline
Return results & boolean \\
%\hline
Pre-conditions & fileName is not null and is not an empty string. \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & I/O exception \\
%\hline
Handling &  Print out an error message and return false. \\ 
%\hline
Comments & This method saves tasks data to an XML file. It returns true on success and false on failure. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PeopleList.getInstance
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.getInstance} \\
%\hline
Arguments & None \\
%\hline
Return results & PeopleList \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & If the singleton PeopleList was null, then it has been constructed. Otherwise, the state does not change. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns the PeopleList singleton. This singleton serves as a model of the table view of people.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PeopleList.getPeopleList
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.getPeopleList} \\
%\hline
Arguments & None \\
%\hline
Return results & List\textless Person\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns a list of Person objects present in the system.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PeopleList.setPeopleList
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.setPeopleList} \\
%\hline
Arguments & ArrayList\textless Person\textgreater \ peopleList \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The ArrayList\textless Person\textgreater object passed as an argument has been assigned to the peopleList List\textless Person\textgreater\ member of the class. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method sets the member data peopleList of PeopleList class to the argument peopleList and fires a property change event. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PeopleList.clear 
%-----------------------------------------------------
%
\hfill 
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.clear} \\
%\hline
Arguments & None \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & All person objects are removed from peopleList \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event to update the views.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PeopleList.addPerson
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.addPerson} \\
%\hline
Arguments & Person person \\
%\hline
Return results & None \\
%\hline
Pre-conditions & person is not null and does not already exist in peopleList.\\
%\hline
Post-conditions & The Person object person has been added to the peopleList. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% PersonTable.saveCSVFile
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{PeopleList.saveCSVFile} \\
%\hline
Arguments & String fileName \\
%\hline
Return results & boolean \\
%\hline
Pre-conditions & fileName is not null and is not an empty string. \\
%\hline
Post-conditions & The state of the module remains the same. \\
%\hline
Exceptions & I/O exception \\
%\hline
Handling &  Print out an error message and return false. \\ 
%\hline
Comments & This method saves people data (names, total number of hours, and a list of assigned tasks) to a CSV file. It returns true on success and false on failure. \\
%\hline
\end{tabular}

%-----------------------------------------------------
% DependencyManager.getInstance
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{DependencyManager.getInstance} \\
%\hline
Arguments & None \\
%\hline
Return results & DependencyManager \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & If the singleton DependencyManager was null, then it has been constructed. Otherwise, the state does not change. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method returns the DependencyManager singleton. This singleton serves as a model of the dependencies among tasks.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% DependencyManager.getDependencyMap 
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{DependencyManager.getDependencyMap} \\
%\hline
Arguments & None \\
%\hline
Return results & DependencyMap \textless Integer, Integer\textgreater \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & The state of the module has not changed. \\
%\hline
Exceptions & None \\
%\hline
Comments & The DependencyMap returned by this method maps the id of the task that should be achieved chronologically first to the second tasks that should be achieved chronologically second.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% DependencyManager.addDependency 
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{DependencyManager.addDependency} \\
%\hline
Arguments & Task first , Task second \\
%\hline
Return results & None \\
%\hline
Pre-conditions & Tasks first and second are not null and there is no circular dependency between them.\\
%\hline
Post-conditions & A dependency is added between tasks first and second. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% DependencyManager.removeDependency 
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{DependencyManager.removeDependency} \\
%\hline
Arguments & Task first \\
%\hline
Return results & None \\
%\hline
Pre-conditions & Task first is not null \\
%\hline
Post-conditions & A dependency of Task first on another task is removed. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% DependencyManager.clear 
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{DependencyManager.clear} \\
%\hline
Arguments & None \\
%\hline
Return results & None \\
%\hline
Pre-conditions & None \\
%\hline
Post-conditions & All dependencies among tasks are removed. \\
%\hline
Exceptions & None \\
%\hline
Comments & This method fires a property change event to update the views.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% createActions
%-----------------------------------------------------
%
\subsubsection{Event Handler Subsystem}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{createActions} \\
%\hline
Arguments & None \\
%\hline
Return results & None \\
%\hline
Pre-conditions & Contents of the application window have been created \\
%\hline
Post-conditions & The following Action objects have been constructed: \begin{enumerate}\itemsep0pt
\item actionHelpAbout 
\item actionFileExit 
\item actionFileExportPeople 
\item actionFileExportTasks 
\item actionFileOpen 
\item actionFileSave
\item actionEditAddTask
\item actionEditAddSubtask
\item actionEditRemoveTask
\item actionEditNewProject 
\end{enumerate} \\
%\hline
Exceptions & None \\
%\hline
Comments & This method creates handlers for actions.  \\
%\hline
\end{tabular}

%-----------------------------------------------------
% initDataBindings
%-----------------------------------------------------
%
\hfill
\vspace*{0.15in}
\begin{tabular}{ l  p{4.85in}  }
%\hline
\bf{Method} & \bf{initDataBindings} \\
%\hline
Arguments & None \\
%\hline
Return results & DataBindingContext \\
%\hline
Pre-conditions & Contents of the application window have been created \\
%\hline
Post-conditions & The following viewer objects have been created and data binding between the corresponding Data Handler and UI structures has been defined:

\begin{enumerate}\itemsep0pt
\item TableViewer tableViewerPeople
\item TableViewer tableViewerTasks
\item TreeViewer treeViewerTasks
\item TMSGanttChart ganttChart
\end{enumerate} \\
& The following TableViewerColumn objects, which are editable columns in the table view of tasks, have been created and data binding between the corresponding Data Handler and UI structures has been defined: \begin{enumerate}\itemsep0pt
\item tableViewerColumnTitle
\item tableViewerColumnDescription
\item tableViewerColumnDuration
\item tableViewerColumnDeliverable
\item tableViewerColumnDeadline
\item tableViewerColumnPerson
\end{enumerate} \\
%\hline
Exceptions & None \\
%\hline
Comments & This method binds data between the Data handler subsystem and the corresponding UI components (see~\ref{ui_subsystem} for more details). \\
%\hline
\end{tabular}

\subsubsection{User Interface Subsystem}
\label{ui_subsystem}

The User interface subsystem does not have direct interfaces with the other subsystems. The Event handler subsystem creates event handlers and data binding between the User interface subsystem and the Data handler subsystem. Changes in the Data handler structures are automatically reflected in the user interface due to the data binding.

Whenever a value is edited in the user interface, this change is propagated to the data model by the corresponding data binding. Whenever a value is changed in the model, a property change event is fired. Due to the data binding, visual controls bound to the model will be notified of any change and update themselves accordingly.

%====================================================
% DETAILED DESIGN
%====================================================
%
\clearpage
\section{Detailed Design} \label{sec:detail}

%====================================================
% Detailed Design - Data Handler Subsystem
%====================================================
%
\subsection{Data Handler Subsystem}

\subsubsection{Detailed Design Diagram}

\begin{figure}[htb]
	\centering
		\includegraphics[width=1.0\textwidth]{img/Data_Handler_subsystem.png}
	\caption{Class diagram for \textit{Data Handler Subsystem}}
	\label{fig:Data_Handling_subsystem}
\end{figure}

This class diagram depicts the internal structure of Data handler subsystem. 
\begin{itemize}\itemsep0pt
\item The Project class is a facade to the Data handler subsystem which handles interaction with other subsystems and hides internal implementation of the Data handler. 
\item The Task class represents a task or a subtask in the TMS that can have zero or more subtasks. 
\item The Person class represents a person assigned to a task. 
\item The TaskTree class manages tasks and subtasks and PeopleList class manages people. 
\item The DependencyManager class represents dependencies betwen tasks in TMS. One of its important responsibilities is to avoid circular dependencies between tasks. 
\item The AbstractModelObject class represents an object with property change support.
\item The data in Data handler subsystem will be synchronized with the views of the User interface using Java and JFace data binding functionality. In order to achieve this, all the classes implement the PropertyChangeListener interface and extend the AbstractObjectModel class.
\end{itemize}

%\clearpage
\subsubsection{Units Description}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK
%====================================================
%
\bigskip
\textbf{Class Task}\\
Purpose: The Task class represents a task that can have subtasks. It extends AbstractModelObject and implements PropertyChangeListener to allow the fire of property changes. \\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK - Attributes
%====================================================
%
\\
\textbf{Attributes}
\\
\\
\begin{tabular}{| l | l | l | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private int &  id & Task ID\\
\hline
private String & title & Task title\\
\hline
private String & description & Task description\\
\hline
private int & duration & Task duration\\
\hline
private String & deliverable & Task deliverable \\
\hline
private Date & deadline & Task due date\\
\hline
private String & person & Name of the person assigned to this task \\
\hline
private ArrayList\textless Task\textgreater & subTasks & Immediate subtasks of this task (or subtask) \\
\hline
private Task & parent & Parent task (or subtask) \\
\hline
private int & beforeId & ID of the task (or subtask) this task depends on \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK - Constructors
%====================================================
%
\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{4in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
public Task() & Constructs an empty task with id = 0; title, description and deliverable = "none"; deadline = current time; duration = 1; subTasks = empty list; beforeId = -1; parent = null; person = "nobody". \\
\hline
\end{tabular}
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK - Methods
%====================================================

\clearpage
\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| l | p{1.5in} |  p{3.5in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public String & toString() & Overrides the default toString() method by producing a String representation based on the attributes of Task. The name of an attribute is followed by its value. \\
\hline
public boolean & equals(Object obj) & Overrides the default equals method by comparing two Task objects by their attributes. \\
\hline
public int & getId() & Getter of the id attribute. \\
\hline
public void & setId(int id) & Setter of the id attribute. If the argument is less than 0, sets id to 0. Fires id change event for data binding. \\
\hline
public String & getTitle() & Getter of the title attribute. \\
\hline
public void & setTitle(String title) & Setter of the title attribute. If the argument is null or an empty string, sets the title to "none". Fires title change event for data binding. \\
\hline
public String & getDescription() & Getter of the description attribute. \\
\hline
public void & setDescription(String description) & Setter of the description attribute. If the argument is null or an empty string, sets the description to "none". Fires description change event for data binding. \\
\hline
public int & getDuration() & Getter of the duration attribute. \\
\hline
public void & setDuration(int duration) & Setter of the duration attribute. If the argument is less than 0, sets the duration to 1. Sets the duration to the highest of the sum of durations of subtasks or the method's argument. If the task has parent, calls setDuration method with parent's duration. Fires duration change event for data binding. \\
\hline
public String & getDeliverable() & Getter of the deliverable attribute. \\
\hline
public void & setDeliverable(String deliverable) & Setter of the deliverable attribute. If the argument is null or an empty string, sets the deliverable to "none". Fires deliverable change event for data binding. \\
\hline
public date & getDeadline() & Getter of the deadline attribute. \\
\hline
public void & setDeadline(Date deadline) & Setter of the deadline attribute. If the argument is null, doesn't update the deadline. Fires deadline change event for data binding. \\
\hline
public String & getPerson() & Getter of the person attribute. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.5in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & setPerson(String Person) & Setter of the person attribute. If the argument is null or empty string, sets the person to "nobody". Updates the associated top-level task and all its subtasks with the new person. Fires person change event for data binding. \\
\hline
public\newline ArrayList\textless Task\textgreater & getSubTasks() & Getter of the subTasks attribute. \\
\hline
private void & setPersonForChildren (Task parent, String person) & Modifies the person attribute of all the subtasks of the task 'parent' recursively. \\
\hline
public Task & getParent() & Getter of the parent attribute. \\
\hline
public void & setParent(Task parent) & Setter of the parent attribute. If the new parent is null, equal to this task or if id of this task is equal the id of the new parent task, exists the method, else sets the parent to the argument passed. Fires parent change event for data binding. \\
\hline
public int & getBeforeId() & Getter of the beforeId attribute. \\
\hline
public void & setBeforeId(int beforeId) & Setter of the beforeId attribute. If this task is a subtask or id of this task is equal to the new beforeId, exists the methods. If the new beforeId is less then 0, sets it to -1. Sets the beforeId to the new beforeId. Fires beforeId change event for data binding. \\
\hline
public boolean & hasChildren() & Returns false if this task has no subtasks, else returns true. \\
\hline
public boolean & hasParent() & Returns true if the Task is a subtask, false if the task is a task (i.e. top level task).\\
\hline
public void & clear() & Method for recursively removing all the subtasks. \\
\hline
public void & addSubtask(Task subtask) & Adds the subtask to this task. If the subtask is null, equal to this task, id of the subtask is equal to id of this task or if the subtask is already in the list of subtasks, exits the method. \\ & & Else adds the subtask to the list of subtasks and sets parent of the subtask to this task; \\ & & If the duration of the subtask is higher then the duration of this task, sets the duration of this task to the duration of the subtask. \\ & & Fires subtasks and duration change events for data binding. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.5in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & removeSubtask(Task subtask) & Method to remove a subtask. If the subtask is null, equal to this task or id of the subtask is equal to id of this task, exits the method. \\ & & Else removes the subtask from the list of subtasks of this task, sets parent of the subtask to null and fires subtasks change event for data binding. \\
\hline
\end{tabular}

%\clearpage
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK-TREE
%====================================================
%
\bigskip
\textbf{Class TaskTree}\\
Purpose: The TaskTree class is a singleton representing the tasks in the TMS. Provides functionality for adding and removing tasks, loading and saving project data from/to XML files and exporting task data to CSV files. It extends AbstractModelObject and implements PropertyChangeListener to allow the fire of property changes. \\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK-TREE - Attributes
%====================================================
%
\\
\textbf{Attributes}
\\
\\
\begin{tabular}{| l | l | p{2.5in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private static final String & HEADER\_STRING & Titles for the CSV output file. \\
\hline
private static TaskTree & s\_instance & The only instance of the TaskTree class. \\
\hline
private TreeMap\textless Integer, Task\textgreater & taskMap & Holds all Task objects associated by taskId.\\
\hline
private ArrayList\textless Task\textgreater & taskList & List of tasks that represents the taskTree. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK-TREE - Constructors
%====================================================
%
\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{4in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
private TaskTree() & Constructs an empty TaskTree instance. The constructor is private in order to make the class a singleton and control the instantiation of this class \textit{via} the getInstance() method. \\
\hline
\end{tabular}
%

%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS TASK-TREE - Methods
%====================================================

\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public\newline static TaskTree & getInstance() & Returns the static s\_instance attribute. If the attribute is null, it is constructed before being returned. \\
\hline
public TreeMap\textless Integer, Task\textgreater & getTaskMap() & Returns taskMap attribute. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.3in} | p{1.7in} |  p{3.3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public\newline ArrayList\textless Task\textgreater & getTaskList() & Returns taskList attribute. \\
\hline
public Task & addTask() & Creates a new task and adds it to the taskList and taskMap. Sets task's id using setUniqueId method. Fires taskTree change event for data binding. Returns the created task. \\
\hline
public void & removeTask\newline (Task task) & If task is null, exists the method. If the argument task is a subtask, uses parent tasks's method removeSubtask to remove the task, else removes the task from taskList directly. \\ & & Removes the task from the taskMap. \\ & & Fires taskTree change event for data binding. \\
\hline  
private boolean & loadSubTasksFromXML (NodeList subTasks,\newline Task parent) & Recursively parses the passed XML NodeList and creates subtasks. The parent argument is the parent task of the subtasks to be parsed. Returns True on success and False on failure. \\
\hline
public boolean & loadXMLFile\newline (String fileName) &  Parses XML file, creates tasks and loads them to taskList and taskMap.\newline Uses loadSubTasksFromXML method for parsing and loading subtasks. \newline Fires taskTree change event for data binding. Returns True on success and False on failure. \\
\hline
public boolean & saveCSVFile\newline (String fileName) & Saves the tasks to a CSV file. If fileName is empty or null or a FileNotFoundException occurs, the method returns false, else true. \\
\hline
public void & propertyChange\newline (PropertyChangeEvent evt) & Fires tableTree change event for data binding. \\
\hline
public void & clear() & Clears taskList and taskTree. Fires taskTree change event for data binding. \\
\hline
public Task & addSubtask\newline (Task parent) & If parent is null or not in the taskMap, exists the method, else adds a new subtask to parent and returns it. Fires taskTree change event for data binding. \\
\hline
private static\newline String & getTagValue\newline (String sTag, \newline Element element) & Returns node value from XML element having tag sTag. \\
\hline
public Task & getTask\newline (int id) & If taskMap contains task with id equal to the passed parameter, returns the associated task, else returns null. \\
\hline
private Task & getTask\newline (Element eElement) & Creates Task object from XML node. Returns the created object. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.3in} | p{1.7in} |  p{3.3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & setUniqueId\newline (Task task) & Finds unused id in the taskMap and sets it to passed task. \\
\hline
public\newline ArrayList \textless Task\textgreater & getTopLevelTasklist() & \\
\hline
public\newline ArrayList \textless Task\textgreater & getTopLevelTasklist() & Returns the top-level tasks from taskList in a flat list (subtasks are excluded). \\
\hline
public\newline ArrayList \textless Task\textgreater & getFlatTasklist() & Returns all tasks and subtasks from taskList in a flat list. \\
\hline
public Boolean & saveXMLFile\newline (String fileName) & Saves tasks from taskList to fileName in XML format.\newline If fileName is null or empty string, exists without saving and returns false. \newline If transformation exepctions occur, returns false, else true. \\
\hline
private void & taskDataToXML\newline (Document doc,\newline Task t,\newline Element parentElem,\newline String task\_hierarchy\_type) & Recursively transforms the task (or subtask) 't' to XML Document doc.\newline parentElem is the parent task represented in XML.\newline task\_hierarchy\_type indicates whether t is a task or a subtask, which sets the corresponding XML tag. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PERSON
%====================================================
%
%\clearpage
\vspace*{0.2in}
\textbf{Class Person}\\
Purpose: Represents a person assigned to a task.  Allows adding a task to the list of tasks this person is assigned to work on. \\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PERSON - Attributes
%====================================================
%
\\
\textbf{Attributes}
\\
\\
\begin{tabular}{| l | p{1.3in} | p{3.5in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private String & name & The name of the person. \\
\hline
private int & hours & Total number of hours of all tasks this person is assigned to work on. \\
\hline
private List\textless Task\textgreater & tasks & Contains all the tasks the person is assigned to. \\
\hline
private static final int & HOURS\_IN\_\newline WORKING\_DAY & A constant for the number of working hours per day. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PERSON - Constructors
%====================================================
%
\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{4in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
public Person() & Constructs a Person object with name = "nobody", hours = 0 and an empty tasks list. \\
\hline
\end{tabular}

%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PERSON - Methods
%====================================================

\clearpage
%\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public String & toString() & Overrides the default toString() method by producing a String representation based on the attributes of Person. Each attribute starts on a new line. The name of an attribute is followed by its value. \\
\hline
public boolean & equals(Object obj) & Overrides the default equals method by comparing two Person objects by their attributes. \\
\hline
public String & getName() & Getter of the name attribute. \\
\hline
public void & setName(String title) & Setter of the name attribute. If the argument is null or an empty string, sets the name to "nobody". Fires name change event for data binding. \\
\hline
public int & getHours() & Getter of the hours attribute. \\
\hline
public List\textless Task\textgreater & getTasks() & Getter of the tasks attribute. \\
\hline
public String & getTaskList() & Returns id values of all the tasks this person is assigned to as a comma delimited string. \\
\hline
public void & addTask(Task task) & 
\begin{itemize}\itemsep0pt
\item Adds the task passed to the method to the tasks attribute. If the task is null or already present in the list of tasks, then the task is not added. If the task is assigned to a different person, the task assignee is changed to this person.
\item If the new task is a top level task (not subtask), the hours of this person will be recalculated according to formula: \newline hours += task.getDuration() \* HOURS\_IN\_WORKING\_DAY; 
\item Fires taskList and hours change events and hours change event.
\end{itemize}\\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PEOPLE-LIST
%====================================================
%
\clearpage
\bigskip
\textbf{Class PeopleList}\\
Purpose: The PeopleList class is a singleton representing the people in the TMS. The class has a functionality for assigning a person to a task and exporting people data in CSV format. It extends AbstractModelObject and implements PropertyChangeListener to allow the fire of property changes. \\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PEOPLE-LIST - Attributes
%====================================================
%
\\
\textbf{Attributes}
\\
\\
\begin{tabular}{| l | l | p{3in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private static final String & HEADER\_STRING & Titles for the CSV output file. \\
\hline
private static PeopleList & s\_instance & The only instance of the PeopleList class. \\
\hline
List\textless Person\textgreater & personList & Holds all person objects. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PEOPLE-LIST - Constructors
%====================================================
%
\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{4.5in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
private PeopleList() & Constructs an empty PeopleList instance. The constructor is private in order to make the class a singleton and control the instantiation of this class \textit{via} the getInstance() method only. \\
\hline
\end{tabular}
%

%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS PEOPLE-LIST - Methods
%====================================================

\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public\newline static PeopleList & getInstance() & Returns the static s\_instance attribute. If the attribute is null, it is constructed before being returned. \\
\hline
public List\textless Person\textgreater & getPeopleList() & Returns personList attribute. \\
\hline
public void & setPersonList(\newline ArrayList\textless Person\textgreater\newline personList) & Setter for the personList attribute. Fires personList change event for data binding. \\
\hline
public boolean & saveCSVFile(String fileName) & Saves people data, including name, hours and assigned tasks to a CSV file. Tasks assigned will be retrieved using the Person.getTaskList() method. If fileName is empty or null or a FileNotFoundException occurs, the method returns false, else true. \\
\hline
public void & propertyChange(\newline PropertyChangeEvent evt) & Fires personList change event for data binding. \\
\hline
\end{tabular}

\clearpage
\begin{tabular}{| p{1.5in} | p{1.5in} |  p{3.2in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & setPeopleList(\newline ArrayList\textless Person\textgreater\newline peopleList) & Sets peopleList attribute from the method's argument. \newline Fires peopleList change event for data binding.\\
\hline
public void & clear() & Clears peopleList value. \newline Fires peopleList change event for data binding.\\
\hline
public void & addPerson(Person person) & If the person object which is argument to the method is null or is already contained in the peopleList, exists the method without changes. Else adds the person to the peopleList and fires peopleList change event for data binding.\\
\hline
public Boolean & saveCSVFile(String fileName) & If fileName is null or empty string, exists the method and returns false. \newline Else saves all persons from peopleList to the file 'fileName' in CSV format. \newline For each person, name, hours and list of assigned tasks are saved. \newline Name is retrieved using getName() method. \newline Hours are retrieved using getHours() method. \newline List of assigned tasks is retrieved using getTasklist() method. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS AbstractModelObject
%====================================================
%
\clearpage
\bigskip
\textbf{Class AbstractModelObject}\\
Purpose: Represents an object with property change support. Other classes from Data Handler subsystem extend AbstractModelObject in order to have the functionality for firing the preperty change events for the data binding.\\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS AbstractModelObject - Attributes
%====================================================

\textbf{Attributes}
\\
\\
\begin{tabular}{| l | p{1.7in} | p{3in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private final & PropertyChangeSupport \newline propertyChangeSupport & A propertyChangeSupport object \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS AbstractModelObject - Methods
%====================================================

\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1in} | p{2.2in} |  p{3.1in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & addPropertyChangeListener\newline (PropertyChangeListener\newline listener) & Adds a property change listener to the property change support. \\
\hline
public void & addPropertyChangeListener\newline(String propertyName,\newline PropertyChangeListener\newline listener) & Adds a property change listener associated with the property name to the property change support. \\
\hline
public void & removePropertyChangeListener\newline (PropertyChangeListener\newline listener) & Removes a property change listener from the property change support. \\
\hline
public void & removePropertyChangeListener\newline (String propertyName,\newline PropertyChangeListener listener) & Removes a property change listener associated with the property name from the property change support. \\
\hline
protected void & firePropertyChange\newline (String propertyName,\newline Object oldValue,\newline Object newValue) & Fires a property update to any registered listeners. \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS DependencyManager
%====================================================
%
\clearpage
\bigskip
\textbf{Class DependencyManager}\\
Purpose: The DependencyManager class is a singleton representing the dependencies between tasks in the TMS. It also resolves duration and deadline conflicts between dependent tasks. It extends AbstractModelObject and implements PropertyChangeListener to allow the fire of property changes. \\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS DependencyManager - Attributes
%====================================================

\textbf{Attributes}
\\
\\
\begin{tabular}{| l | p{1.5in} | p{2.2in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private static & DependencyManager & The unique instance of the class.\\
\hline
private TreeMap\textless Integer, Integer\textgreater & dependencyMap & Holds all dependencies between tasks in a form of (Task.Id, Task.Id) \\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS DependencyManager - Constructors
%====================================================

\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{3.5in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
private DependencyManager() & Private constructor to prevent the creation the multiple instances of the class.\\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS DependencyManager - Methods
%====================================================

\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1.2in} | p{2.2in} |  p{3.1in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public static & DependencyManager getInstance() & Returns the single instance of the class. \\
\hline
public TreeMap\textless Integer, Integer\textgreater & getDependencyMap() & Returns the dependencyMap attribute. \\
\hline
public void & addDependency(Task first,\newline Task second) & If first or second is null or same object, exits the method. Else adds dependency between first and second to dependencyMap, adds PropertyChangeListener for the first and second objects and fires dependencyMap change event for data binding.\\
\hline
public void & removeDependency(Task first) &  If first is null, exits the method. Else removed task ID of the task 'first' from dependencyMap and fires dependencyMap change event for data binding. \\
\hline
public void & clear() & Clears the dependencyMap and fires dependencyMap change event for data binding. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.4in} | p{2in} |  p{3.1in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
private void & resolveDependencies\newline (Task task, int oldBeforeId) & 
\begin{itemize}\itemsep0pt
\item Resolves dependencies between tasks.
\item If the current (new) beforeId of the task is -1 or if the new before task doesn't exist, removes the new dependency from the dependencyMap using removeDependency() method. 
\item If the new dependency introduces a circular reference, the change is undone by removing the new dependency and adding the old dependency contained in oldBeforeId. 
\end{itemize}\\
\hline
private boolean & isCircular(Task task) & Returns true if task is involved in a circular dependency by checking the chain of beforeIds starting from task's id and testing whether task is found in the dependency chain later on. \newline Returns false otherwise.\\
\hline
private void & resolveOverlaps() & Iterates over all existing dependencies and checks if the deadline of a first task overlaps with the start date of the second task. If yes, the deadline of the second task is pushed back.\newline If at least one overlap was resolved, dependencyMap property change event is fired for data binding.\\
\hline
public void & propertyChange\newline (PropertyChangeEvent evt) & According to the Property Name of the evt event performs the following:
\begin{itemize}\itemsep0pt
\item If event is a duration change, calls resolveOverlaps() method.
\item If event is a deadline change, calls resolveOverlaps() method.
\item If event is a beforeId change and event's source is a Task, calls resolveDependencies() method with old beforeId. Evt's source is retrieved using getSource() method and old beforeId is retrievd using getOldValue() method on the evt.
\end{itemize}\\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS Project
%====================================================
%
\clearpage
\bigskip
\textbf{Class Project}\\
Purpose: Serves as a facade of the Data handler subsystem through which other subsystems interact with it.\\
%
%====================================================
% Detailed Design - Data Handler Subsystem - CLASS Project - Attributes
%====================================================

\textbf{Attributes}
\\
\\
\begin{tabular}{| l | p{1.5in} | p{3in} | }
\hline
\textbf{Visibility and Type} & \textbf{Name} & \textbf{Description}\\
\hline
private static & Project s\_instance & The only instance of the class.\\
\hline
private PeopleList & peopleList & The only instance of the peopleList class. \\
\hline
private TaskTree & taskTree & The only instance of the taskTree class.\\
\hline
private DependencyManager & dependencyManager & The only instance of the DependencyManager class.\\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS Project - Constructors
%====================================================

\vspace*{0.2in}
\textbf{Constructors}
\\
\\
\begin{tabular}{| l | p{4.5in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
private Project() & 
\begin{itemize}\itemsep0pt
\item The private constructor in order to ensure the singleton design pattern by controlling class instantination via getInstance() method.
\item Sets the peopleList, taskTree and dependencyManager attributes by calling getInstance() methods of the corresponding classes.
\item Registers a listener to the taskTree for updating on changes
\item Registers a listener to the dependencyManager for updating on changes
\end{itemize}\\
\hline
\end{tabular}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS Project - Methods
%====================================================

\vspace*{0.2in}
\textbf{Methods}
\\
\\
\begin{tabular}{| p{1.4in} | p{2in} |  p{3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public static & Project getInstance() & Getter of the only instance of the class. If the instance is null, constructs it before returning.\\
\hline
public TaskTree & getTaskTree() & Getter of the taskTree attribute.\\
\hline
public\newline DependencyManager & getDependencyManager() & Getter of the dependencyManager attribute.\\
\hline
public TreeMap\newline \textless Integer, Integer\textgreater & getDependencyMap() & Returns the output of getDependencyMap() method of DependencyManager class via the dependencyManager attribute.\\
\hline
\end{tabular}

\begin{tabular}{| p{1.4in} | p{2in} |  p{3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public List\textless Person\textgreater  & getPeopleList() & Returns the list of people assigned to tasks by calling getPeopleList() method of PeopleList class via peopleList attribute.\\
\hline
private void & setPeopleList() & 
\begin{itemize}\itemsep0pt
\item Iterates through all the tasks retrieved by taskTree.getFlatTasklist() method and adds people to TreeMap\textless String, Person\textgreater\newline personMap object. 
\item Clears the list of people using\newline peopleList.clear() method.
\item Adds all people from personMap to peopleList using peopleList.addPerson() method.
\end{itemize}\\
\hline
public \newline ArrayList\textless Task\textgreater & getTasklist() & Returns a list of all top-level using\newline taskTree.getTasklist() method.\\
\hline
public \newline ArrayList\textless Task\textgreater & getFlatTasklist() & Returns the tasks and subtasks in a flat list for displaying in the table of tasks using taskTree.getFlatTasklist() method.\\
\hline
public \newline ArrayList\textless Task\textgreater & getTopLevelTasklist() & Returns the tasks and subtasks in a flat list for displaying in the table of tasks using taskTree.getTopLevelTasklist() method.\\
\hline
public Task & addTask() & 
\begin{itemize}\itemsep0pt
\item Adds a new default task to the tasks list using taskTree.addTask() method.
\item Registers the task for listening to the Project and dependencyManager events.
\item Fires project change event for data binding.
\item Returms the new task.
\end{itemize}\\
\hline
public Task & addSubtask(Task parent) & Same as addTask() besides that creates a subtask (not task) under the parent using taskTree.addSubtask(parent) method. \\
\hline
\end{tabular}

\begin{tabular}{| p{1.4in} | p{2in} |  p{3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
public void & removeTask(Task task) & Calls removeTask() method of taskTree object with task as a parameter. Fires project change event for data binding.\\
\hline
public void & clear() & Calls clear() methods of taskTree and peopleList objects. Fires project change event for data binding.\\
\hline
public Boolean & loadProjectFile\newline (String fileName) & 
\begin{itemize}\itemsep0pt
\item Calls loadXMLFile() method of the taskTree object. 
\item If the method returned false, exists returning false.
\item Clears peopleList and dependencyManager.
\item For all top-level tasks registers listeners for the project and dependencyManager events.
\item For tasks having dependencies adds dependencies to dependencyManager. 
\end{itemize}\\
\hline
public boolean & saveProjectFile\newline (String selectedFile) & Calls saveXMLFile() method of taskTree object and returns its true/false status.\\
\hline
public Boolean & savePeopleList\newline (String fileName) & Calls saveCSVFile() method of peopleList object and returns its true/false status.\\
\hline
public Boolean & saveTaskList\newline (String fileName) & Calls saveCSVFile() method of taskTree object and returns its true/false status.\\
\hline
public void & propertyChange\newline (PropertyChangeEvent evt) & 
\begin{itemize}\itemsep0pt
\item Updates the peopleList using\newline setPeopleList() method.
\item Fires the property change events: project, tasktree, tasklist, flatTasklist, peopleList and dependencyMap.
\end{itemize}\\
\hline
\end{tabular}


%====================================================
% Detailed Design - User Interface and Event Handler Subsystem
%====================================================
%
\clearpage
\subsection{User Interface and Event Handler Subsystem}

Major parts of the User interface and Event handler code are auto-generated by Window Builder and its data binding functionality. As a result, the User interface and Event handler code are combined in the same class and cannot be easily separated. Since the code is located in the same class, a UML class diagram has not been presented and the User interface and Event handler subsystems will be described as one subsystem for detail design purposes.

\subsubsection{Units Description}

%====================================================
% Detailed Design - Data Handler Subsystem - CLASS Main
%====================================================
%
\bigskip
\textbf{Class Main}\\
\\
Purpose: Contains User interface and Event handler code. Includes functionality for creating an application window, action handlers (for actions Help, About, Exit, Export People, Export Tasks, Open Project File), menu manager, tool bar manager, status line manager and data binding between the Data handler subsystem and User interface views. \\
%
%=======================================================
% Detailed Design - User Interface and Event Handler Subsystem - CLASS Main - Attributes
%=======================================================
%
\\
\textbf{Attributes}\\
\begin{longtable}{| p{1.5in} | p{1.8in} | p{3in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
\endfirsthead 
\multicolumn{3}{@{}l}{\ldots continued}\\
\hline 
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline 
\endhead
%
% DATA HANDLER INSTANCES / DATA BINDING
%
package DataBindingContext & m\_bindingContext & Contains the data binding context. \\
\hline
private Project & project & Contains the singleton instance of the Project class. \\
\hline
%
% ACTIONS
%
private Action & actionHelpAbout & Contains Action object for 'About' action. \\
\hline
private Action & actionFileExit & Contains Action object for 'Exit' action. \\
\hline
private Action & actionFileExportPeople & Contains Action object for 'Export people' action. \\
\hline
private Action & actionFileExportTasks &  Contains Action object for 'Export tasks' action. \\
\hline
private Action & actionFileOpen & Contains Action object for 'Open file' action. \\
\hline
private Action & actionFileSave & Contains Action object for 'Save file' action. \\
\hline
private Action & actionEditNewProject & Contains Action object for 'New project' action. \\
\hline
private Action & actionEditAddTask & Contains Action object for 'Add task' action. \\
\hline
private Action & actionEditAddSubtask & Contains Action object for 'Add subtask' action. \\
\hline
private Action & actionEditRemoveTask & Contains Action object for 'Remove task' action. \\
\hline

%
% Widths for table columns
%
final static int & WIDTH\_ID & The width of the ID column in the table view of tasks. Value is 35. \\
\hline
final static int & WIDTH\_TITLE & The width of the Title column in the table view of tasks. Value is 90. \\
\hline
final static int & WIDTH\_DESCRIPTION & The width of the Description column in the table view of tasks. Value is 120. \\
\hline
final static int & WIDTH\_DURATION & The width of the Duration column in the table view of tasks. Value is 60. \\
\hline
final static int & WIDTH\_DELIVERABLE & The width of the Deliverable column in the table view of tasks. Value is 140. \\
\hline
final static int & WIDTH\_DEADLINE & The width of the Deadline column in the table view of tasks. Value is 170. \\
\hline
final static int & WIDTH\_PERSON & The width of the Person Name column in the table view of tasks. Value is 90. \\
\hline
final static int & WIDTH\_BEFORE\_ID & The width of the BeforeID column in the table view of tasks. Value is 60. \\
\hline
final static int & WIDTH\_NAME & The width of the Name column in the table view of people. Value is 90. \\
\hline
final static int & WIDTH\_HOURS & The width of the Hours column in the table view of people. Value is 40. \\
\hline
final static int & WIDTH\_TASKS & The width of the Tasks column in the table view of people. Value is 100. \\
\hline
%
% Table viewers
%
private TableViewer & tableViewerTasks & Table View of Tasks. \\
\hline
private TableViewer & tableViewerPeople & Table View of People. \\
\hline
private TreeViewer & treeViewerTasks & Tree View of Tasks. \\
\hline
private TMSGantt\newline Chart & ganttChart & Gantt Chart of Tasks. \\
\hline
%
% Column viewers
%
private TableViewerColumn & tableViewerColumn-\newline Id & An ID column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Title & A Title column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Description & A Description column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Duration & A Duration column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Deliverable & A Deliverable column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Deadline & A Deadline column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Person & A Person column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline BeforeId & A BeforeID column in the Table View of Tasks. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Hours & An Hours column in the Table View of People. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Name & A Name column in the Table View of People. \\
\hline
private TableViewerColumn & tableViewerColumn-\newline Tasks & A Tasks column in the Table View of People. \\
\hline
\end{longtable}

%====================================================
% Detailed Design - User Interface and Event Handler Subsystem - CLASS Main - Constructors
%====================================================
%
\textbf{Constructors}
\begin{longtable}{| p{1.4in} | p{4.9in} | }
\hline
\textbf{Name} & \textbf{Description}\\
\hline
public Main() & Instantiates Action objects using createActions() method.\newline Adds a tool bar by calling addToolBar method.\newline Adds a menu bar by calling addMenuBar method. \newline Adds a status line by calling addStatusLine method. \\
\hline
\end{longtable}
%

%
%=====================================================
% Detailed Design - User Interface and Event Handler Subsystem - CLASS Main - Methods
%=====================================================

\vspace*{0.2in}
\textbf{Methods}
\begin{longtable}{| p{1.3in} | p{1.5in} | p{3.5in} | }
\hline
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline
\endfirsthead 
\multicolumn{3}{@{}l}{\ldots continued}\\
\hline 
\textbf{Visibility, Type} & \textbf{Name} & \textbf{Description}\\
\hline 
\endhead
protected Control & createContents\newline (Composite parent) & Contains code auto-generated by Window Builder which creates the contents of the application window. \\
\hline
private void & createActions() & Instantiates Action attributes of the class as follows: \begin{itemize}\itemsep0pt
\item actionHelpAbout: instantiates About class and calls its open() method.
\item actionFileExit: calls close() method
\item actionFileExportPeople: calls savePeopleFile() method. If savePeopleFile() returns true, updates status line with a success message.
\item actionFileExportTasks: calls saveTasksFile() method. If saveTasksFile() returns true, updates status line with a success message.
\item actionFileOpen: calls openProjectFile() method. If openProjectFile() returns true, updates status line with a success message.
\item actionFileSave: calls saveProjectFile() method. If saveProjectFile() returns true, updates status line with a success message.
\item actionEditAddSubtask: checks if a Task is selected and calls addSubtask(task) method of the Project class. task is the selected task. Updates status line with a success message.
\item actionEditAddTask: calls addTask() method of the Project class. Updates status line with a success message.
\item actionEditNewProject: calls clear() method of the Project class. Updates status line with a success message.
\item actionEditRemoveTask: checks if a Task is selected and calls removeTask(task) method of the Project class. task is the selected task. Updates status line with a success message.
\end{itemize} \\
& & Status bar is updated using setStatus(String msg) method. \\
\hline
private String & getOpenFileName\newline XML() & Selects input XML file for loading project data to TMS. Returns the selected file name.\\
\hline
private String & getSaveFileName\newline CSV(String title) & Selects output file where tasks or people data will be saved in CSV format. title is the title of the file dialog. Returns the selected file name.\\
\hline
private String & getSaveFileName\newline XML(String title) & Selects output file where project data will be saved in XML format. Returns the selected file name.\\
\hline
private boolean & openProjectFile() & Calls getOpenFileNameXML() and loadProjectFile method from Project class to load the data from the file. Returns true on success and false on failure. \\
\hline
private boolean & savePeopleFile() & Calls getSaveFileNameCSV() and savePeopleList(selectedFile) from Project class. Returns true on success and false on failure.\\
\hline
private boolean & saveTasksFile() & Calls getSaveFileNameXML() and saveTaskList(selectedFile) from Project class. Returns true on success and false on failure.\\
\hline
private boolean & saveProjectFile() & Selects output file where project data will be saved in XML format. Calls saveProjectFile(selectedFile from Project class). Returns true on success and false on failure.\\
\hline
protected\newline MenuManager & createMenu-\newline Manager() & Creates a menuManager and adds the following actions: actionFileOpen, actionFileExportTasks, actionFileExportPeople, actionFileExit, menuManagerHelp, actionHelpAbout. Returns the menuManager. \\
\hline
protected\newline ToolBarManager & createToolBar-\newline Manager(int style) & Creates a toolBarManager and adds the following actions: actionFileOpen, actionFileExportTasks, actionFileExportPeople. Returns the toolBarManager. \\
\hline
protected\newline StatusLineManager & createStatus-\newline LineManager() & Creates and returns a statusLineManager. \\
\hline
public static void & main(String args[]) & Instantiates the Main class, in a new thread and calls its open() method. \\
\hline
protected\newline DataBinding\newline Context & initDataBindings() & Contains code auto-generated by the Window Builder data binding wizard which binds data from the Data handler subsystem to the corresponding User interface views. 

\begin{itemize}\itemsep0pt
\item The top-level nodes of the treeViewerTasks are bound to the Task objects in the tasklist attribute of the Project instance, whereas the child nodes are bound to the Task objects in the subtasks attribute of each Task. The title of each task/subtask is used to display in the treeviewer.
\item The tableViewerTasks is bound to the flatTasklist attribute of the Project instance: every task and subtask is displayed in a row of the table with its subtasks following immediately. Due to the databinding, changes made in the table are reflected in the Project instance and vice versa. For this to work, it is imperative to provide property change support for all classes involved. Editing of the task attributes is made possible by defining simple text editors for each attribute except for the task ID (which is not intended to be editable). The editors provide basic input format checking for integers and dates, \textit{i.e.} invalid entries are discarded automatically.
\item The tableViewerPeople is bound to the peopleList attribute of the Project instance. Every person that has at least one task assigned is displayed in a row with name, hours and tasks assigned columns. Like the treeViewerTasks, the tableViewerPeople is not editable.
\end{itemize} \\
\hline
\end{longtable}

%====================================================
% Dynamic Design Scenarios
%====================================================
%
\clearpage
\section{Dynamic Design Scenarios}

The \textit{Add Task} and \textit{Export Tasks} use cases are the basis for the following dynamic design scenarios.
%Describe some (at least two) important execution scenarios of the system using UML sequence diagrams.
%These scenarios must demonstrate how the various subsystems and units are interacting to achieve a system-level service.
%Units and subsystems depicted here must be compatible with the descriptions provided in
%section \ref{sec:arch} and \ref{sec:detail}.

\begin{figure}[htb]
	\centering
		\includegraphics[width=0.8\textwidth]{img/Sequence_diagram_add_task.png}
	\caption{Sequence diagram for use case \textit{Add Task}}
	\label{fig:Sequence_diagram_add_task}
\end{figure}

\begin{figure}[htb]
	\centering
		\includegraphics[width=0.8\textwidth]{img/Sequence_diagram_export_tasks.png}
	\caption{Sequence diagram for the use case Exports Tasks}
	\label{fig:Sequence_diagram_export_tasks}
\end{figure}


%====================================================
% USER INTERFACE
%====================================================
%
\clearpage
\section{User Interface}

\begin{figure}[htb]
	\centering
		\includegraphics[width=1.00\textwidth]{img/ui.png}
	\caption{Graphical user interface mockup}
	\label{fig:ui}
\end{figure}

The TMS has a modern user interface with menu (1), toolbar (2) and status bar (7). The menu gives the user access to all the functions the TMS can perform (\textit{e.g.} add a task, export a table) while the toolbar provides access to the most frequently used options to increase the user efficiency and reduce UI clutter. The status bar displays relevant information or hints to guide the user.

The tree view (3) displays the tasks of a project in a tree-like structure and as a result clearly indicates the subtask relationships within the project. The user can easily expand and collapse individual tasks.

The tasks table (4) displays the details about the currently selected task or subtask. When the project node (\textit{i.e.} the root node) is selected, the table shows all the tasks of the project.

The people table (5) shows which person is assigned to the selected task. When the project node is selected, the information about all the people working on the project will be given here.

The Gantt chart (6) illustrates the sequence of tasks based on their deadlines and duration. It also indicates dependency relationships (\textit{e.g.} Task 2 and Task 3).


\end{document}
